<?php
/**
 * Created by JetBrains PhpStorm.
 * User: CuongDD5
 * Date: 5/8/13
 * Time: 12:20 PM
 * To change this template use File | Settings | File Templates.
 */
include 'mySQLConnect.php';
$id = $_POST['id_news'];
$name = urlencode($_POST['name']);
$image_url = $_POST['image_url'];
$description = urlencode($_POST['description']);
$short_desc = urlencode($_POST['short_desc']);



if ($id != 'null') {
    $qry1 = "UPDATE news SET name = '$name', description = '$description', image_url = '$image_url', short_desc = '$short_desc'  WHERE id = '$id' ";
    if (mysql_query($qry1)) {
        echo "Cập nhật thành công!";
    } else {
        echo "<span style='color: red'>Cập nhật thất bại</span>";
    }
} else {
    $qry1 = "INSERT INTO news (name,short_desc,description,image_url) values ('$name','$short_desc','$description','$image_url') ";

    if (mysql_query($qry1)) {
        echo "Tạo mới tin tức thành công!";
    } else {
        echo "<span style='color: red'>Có lỗi xảy ra</span>";
    }
}

include 'mySQLClose.php';

?>
